<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>BOOST_DATA_TEST_CASE</title>
<link rel="stylesheet" href="../../../boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Boost.Test">
<link rel="up" href="../test_org_reference.html" title="Tests declaration and organization">
<link rel="prev" href="test_org_boost_test_case_parameter.html" title="BOOST_PARAM_TEST_CASE">
<link rel="next" href="test_org_boost_test_dataset_fixture.html" title="BOOST_DATA_TEST_CASE_F">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="test_org_boost_test_case_parameter.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../test_org_reference.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="test_org_boost_test_dataset_fixture.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="boost_test.utf_reference.test_org_reference.test_org_boost_test_dataset"></a><a class="link" href="test_org_boost_test_dataset.html" title="BOOST_DATA_TEST_CASE"><code class="computeroutput"><span class="identifier">BOOST_DATA_TEST_CASE</span></code></a>
</h4></div></div></div>
<p>
          Declares and registers a data-driven test case, using a particular dataset.
        </p>
<p>
          Several forms of the macro are available.
        </p>
<pre class="programlisting"><span class="identifier">BOOST_DATA_TEST_CASE</span><span class="special">(</span><span class="identifier">test_case_name</span><span class="special">,</span> <span class="identifier">dataset</span><span class="special">)</span>
<span class="special">{</span>
  <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">sample</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
          should be used for datasets with arity 1. In the body of the test case,
          the samples of the dataset are taken by the variable <code class="computeroutput"><span class="identifier">sample</span></code>.
        </p>
<pre class="programlisting"><span class="identifier">BOOST_DATA_TEST_CASE</span><span class="special">(</span><span class="identifier">test_case_name</span><span class="special">,</span> <span class="identifier">dataset</span><span class="special">,</span> <span class="identifier">var1</span><span class="special">)</span>
<span class="special">{</span>
  <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">var1</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
          same as the first form, but the samples are taken by the variable <code class="computeroutput"><span class="identifier">var1</span></code> instead of the variable <code class="computeroutput"><span class="identifier">sample</span></code>
        </p>
<pre class="programlisting"><span class="identifier">BOOST_DATA_TEST_CASE</span><span class="special">(</span><span class="identifier">test_case_name</span><span class="special">,</span> <span class="identifier">dataset</span><span class="special">,</span> <span class="identifier">var1</span><span class="special">,</span> <span class="identifier">var2</span><span class="special">...,</span> <span class="identifier">varN</span><span class="special">)</span>
<span class="special">{</span>
  <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">var1</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span>
  <span class="comment">//...</span>
  <span class="identifier">BOOST_TEST</span><span class="special">(</span><span class="identifier">varN</span> <span class="special">!=</span> <span class="number">0</span><span class="special">);</span>
<span class="special">}</span>
</pre>
<p>
          same as the second form, but for dataset of arity <code class="computeroutput"><span class="identifier">N</span></code>.
        </p>
<p>
          For compilers <span class="bold"><strong>lacking the variadic template</strong></span>
          support, the maximal arity (the maximal value of <code class="computeroutput"><span class="identifier">N</span></code>)
          is controlled by the macro <code class="computeroutput"><span class="identifier">BOOST_TEST_DATASET_MAX_ARITY</span></code>
          which is set to <code class="computeroutput"><span class="number">10</span></code> by default.
          If you need a greater value, define <code class="computeroutput"><span class="identifier">BOOST_TEST_DATASET_MAX_ARITY</span></code>
          to the desired value <span class="bold"><strong>before</strong></span> including
          the <span class="emphasis"><em>Unit Test Framework</em></span> headers.
        </p>
<p>
          See <a class="link" href="../../tests_organization/test_cases/test_case_generation/datasets_auto_registration.html" title="Declaring and registering test cases with datasets">here</a>
          for more details.
        </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2001-2022 Boost.Test contributors<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="test_org_boost_test_case_parameter.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../test_org_reference.html"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="test_org_boost_test_dataset_fixture.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
